<? 
session_start();
if(!session_is_registered(uid)){
    echo "You have to login to view this page!</br></br>";
    echo "Click here to return to the "; 
    echo '<a href="./../index.php" title="Login">Login Page</a></br></br>';
    echo "Or sign up using this link ";
    echo '<a href="./../Registration/registration.html" title="Registration">Registration Page</a>';
exit();
}
else

    //Manual SQL Connection
    $con = mysql_connect("localhost", "root", "root") or die ( "Error connectiong to DB: ".mysql_error());
       
    mysql_select_db("reeferslog", $con) or die ( "Error selecting specific DB, reefeerslog: ".mysql_error());
    
    //Prompts for deletion
    if (!isset($_GET['do']) || $_GET['do'] !=1) {
    
       switch($_GET['type']) {
        case 'test':
            echo 'Are you sure you want to delete this test log? <br\>';    
        break;
       }
        
    echo '<a href="' . $_SERVER['REQUEST_URI'] . '&do=1">Yes</a> '; //yes delete
    echo 'or <a href="viewtests.php">No</a>'; //no return to tank views
    } else {
        switch ($_GET['type']) {
            case 'test':
                //Query to delete value
                $deletetest = "delete from water_tests where user_id = '".$_SESSION['uid'] ."' and test_date='".$_GET['test_date']."'";
                
                
                $result = mysql_query($deletetest,$con) or die('Error: ' . mysql_error());
?>

<p style="text-align: center;"> Your test has been deleted.</br>
    <a href ="./../WelcomePage/WelcomePage.php">Return to Categories</a></br>
    <a href ="viewtests.php">Return to Water Test Log</a></p>
<?php
    break;
        }
    }
?>